<template>
	<view>
		<view class="padding">
			<view class="text-center  padding-top-lg">
				<image class="margin-top-lg" src="/static/logo.png" style="width: 200px;" mode="aspectFit"></image>
			</view>
			<view class="content">
				<view>申请获取以下权限</view>
				<text>获得你的公开信息(昵称，头像、地区等)</text>
			</view>
			<view style="padding: 0 55rpx;">
				<button class="cu-btn block bg-blue margin-tb-sm lg round" type="" @tap="getUserProfile" style="height: 100rpx;">授权登录</button>
			</view>
		<!-- 	<view class="text-box">
				<view class="left">
					<u-checkbox-group v-model="checkboxValue1">
						<u-checkbox :name="checked" activeColor="#00A0E9" shape="circle"></u-checkbox>
					</u-checkbox-group>
				</view>
				<view class="right">
					<text>我已阅读并同意</text>
					<text style="color: #00A0E9;" @click="toAgreementPage(1)">《用户服务协议》</text>
					<text>及</text>
					<text style="color: #00A0E9;" @click="toAgreementPage(2)">《隐私协议》</text>
				</view>
			</view> -->
		</view>
	</view>
</template>

<script>
	import {
		wxmlogin
	} from '@/api/api.js';
	export default {
		data() {
			return {
				checked: 'checked',
				checkboxValue1: [],
				value: ''
			}
		},
		methods: {
			toAgreementPage() {
				// if (type == 1) {
				// 	uni.navigateTo({
				// 		url: '/pages/user/agreement'
				// 	})
				// } else {
				// 	uni.navigateTo({
				// 		url: '/pages/user/question'
				// 	})
				// }
			},
			getUserProfile() {
				console.log(this.value)
				//if (!this.checkboxValue1.length) return uni.$u.toast('请同意并认真阅读协议')
				let that = this;
				uni.getUserProfile({
					desc: '登录',
					success: (info) => {
						//这里取到的是用户的信息，自己安排自己的业务
						uni.login({
							provider: 'weixin',
							success: (res) => {
								wxmlogin({
									code: res.code,
									wxUserInfo: info.userInfo
								}).then(res => {
									console.log(res)
									if (res.code == 200) {
										that.$store.commit('setToken', res.data.token)
										that.$store.commit('setUserInfo', res.data
											.userInfo)
										uni.setStorageSync('token', res.data.token);
										uni.setStorageSync('userInfo', res.data.userInfo);
										uni.switchTab({
											url: "/pages/index/index"
										})
									}

								})
							}
						})
					},
					fail: (err) => {
						console.log(err);
					}
				})
			}

		}
	}
</script>

<style lang="scss">
	.text-box {
		display: flex;
		padding: 0 55rpx;
		padding-top: 20rpx;
		font-size: 28rpx;
		color: #666666;

		.left {
			margin-right: 20rpx;
		}

		.right {}
	}

	.header {
		margin: 90rpx 0 90rpx 50rpx;
		border-bottom: 1px solid #ccc;
		text-align: center;
		width: 650rpx;
		height: 300rpx;
		line-height: 450rpx;
	}

	.header image {
		width: 200rpx;
		height: 200rpx;
	}

	.content {
		margin-left: 50rpx;
		margin-bottom: 90rpx;
	}

	.content text {
		display: block;
		color: #9d9d9d;
		margin-top: 40rpx;
	}

	.bottom {
		border-radius: 80rpx;
		margin: 70rpx 50rpx;
		font-size: 35rpx;
	}
</style>
